package org.travel.app.service;
import com.github.pagehelper.PageInfo;
import org.apache.ibatis.annotations.Param;
import org.travel.app.entity.ConsumePoints;
import org.travel.app.entity.PointsTransactions;
import org.travel.app.entity.spots.Spots;
import org.travel.app.entity.spots.SpotsShopTicket;
import org.travel.app.entity.spots.SpotsTicketPackage;
import org.travel.app.entity.ticket.TicketStock;
import org.travel.app.entity.user.UserDiscountTicket;
import org.travel.app.entity.spots.SpotsTickets;
import org.travel.app.entity.ticket.TicketDiscount;
import org.travel.app.entity.ticket.TicketPackages;
import org.travel.app.entity.ticket.UserTicketDiscount;

import java.util.List;

/**
 * @author nmm
 * @date 2024-12-2024/12/19
 * @deriction njm......
 */
public interface TicketService {

    /**
     * 通过景点id查询景点票
     * @param spotsId
     * @return
     */
    List<SpotsTickets> getSpotsTicketById(Integer spotsId);

    /**
     * 减库存
     * @param stockUd
     */
    void reduceStock(int stockUd);



    /**
     * 通过景点id查询相关套餐
     * @param spotsId
     * @return
     */
    List<TicketPackages> getTicketPackagesBySpotsId(int spotsId);


    /**
     * 统计套餐所用的景点票
     * @param package_id
     * @return
     */
    TicketStock countPackageTicket(int package_id);

    /**
     * 减套餐库存
     * @param ticketTypeId
     */
    void reducePackageStock(int ticketTypeId,int reduceNum);


    /**
     * 通过可选票数查询套餐类型
     * @param packageId
     * @return
     */
    int   getSpotsPackageChoice(@Param("packageId")int packageId);

    /**
     * 返回不同票种的类型id
     * @param packageId
     * @return
     */
  void getSpotsPackageTicketTypeId(@Param("packageId") int packageId);

    /**
     * 减不同票种套餐的库存
     */
    void  reduceDifferentTicketPackage(@Param("ticketTypesId") List<Integer> ticketTypesId);



    /**
     * 查询所有优惠券
     * @return
     */
    List<TicketDiscount>  getTicketDiscountList();


    /**
     * 交易前先查询是否有足够的积分
     * @param transactions
     * @return
     */
    String ensureUserHasPoints(@Param("userTransaction") PointsTransactions transactions);


    /**
     * 添加优惠券
     *
     * @param ticketDiscount
     */
    void addTicketDiscount(UserTicketDiscount ticketDiscount);


    /**
     * 交易优惠券
     */
    void transactionTicket( PointsTransactions transactions);


    /**
     *  添加用户优惠券交易记录(积分兑换优惠券)
     */
    void addUserTransactionTicket( PointsTransactions transactions);


    /**
     * 记录用户所兑换的优惠券(第一次兑换)
     * @param transactions
     */
    void addUserHasTicket(PointsTransactions transactions);


    /**
     * 判断是否有兑换相同的优惠券(如果有则执行修改数量，没有则执行addUserHasTicket)
     */
    Integer   hasDiscountTicket( PointsTransactions transactions);


    /**
     * 用户兑换优惠券(第二次兑换)
     * @param transactions
     */
    void userTransactionTicket(PointsTransactions transactions);



    /**
     * 查询用户所拥有的优惠券
     * @return
     */
    List<UserTicketDiscount> getUserHasTicketList(int userId);


    /**
     * 查询前端优惠券
     * @return
     */
    List<Spots> getDistinctTicketDiscount();

    /**
     * 后台查询所有优惠券
     * @return
     */
    PageInfo<TicketDiscount> getTicketDiscountsList(int pageNum,int pageSize);

    /**
     * 用户使用优惠券
     * @param userDiscountTicket
     */
    void userUsingTicket(UserDiscountTicket userDiscountTicket);


    /**
     * 用户消费随机赠送积分
     */
    void addUserPoint(ConsumePoints consumePoints);


    /**
     * 查询在售景点票
     * @param pageNum
     * @param pageSize
     * @return
     */
    PageInfo<SpotsShopTicket>  getSpotsShopTicketList( int pageNum,int pageSize);

    /***
     * 查询景点套餐
     * @param pageNum
     * @param pageSize
     * @return
     */
    PageInfo<TicketPackages> getSpotsPackage(int pageNum,int pageSize);


    /**
     * 获取前端显示景点套餐
     * @return
     */
    List<TicketPackages>  getCustomSpotsPackage();


    /**
     * 用于添加优惠券显示套餐
     * @return
     */
    List<TicketPackages> getSpotsPackages();

    /**
     * 添加在售景点票
     * @param spotsTickets
     */
    void  addSpotsTicket(SpotsTickets spotsTickets);


    /**
     * 添加景点套餐
     * @param ticketPackages
     */
    void addTicketPackage(TicketPackages ticketPackages);

    /**
     * 删除景点套餐
     * @param packageId
     */
    void delTicketPackage(@Param("packageId") int packageId);

    /**
     * 添加景点套餐管理
     * @param list
     */
    void  addSpotsTicketPackage(List<SpotsTicketPackage > list, int ticketNum,int packageId);


    /**
     * 添加套餐景点关联
     * @param spotsId
     * @param packageId
     */
    void  addPackSpots(@Param("spotsId") int[] spotsId,@Param("packageId") int packageId);

}